#include <allegro.h>
#include <stdio.h>
#include "menu.h"
#include "criminal.h"


void touches (BITMAP *Buffer,BITMAP *menu[4], BITMAP *instruction, BITMAP *level1, BITMAP *present, BITMAP *darkness,BITMAP *office,BITMAP *sallebain, int *i)
{
BITMAP *youmust;
BITMAP *Background;

image image1;
image image2;
image image3;
image image4;
image image5;
image image6;
image image7;
image image8;
image image9;
image image10;
image image11;
image image12;

BITMAP* curseur;

box box1;
box box2;
box box3;
box box4;
box box5;
box box6;
box box7;

BITMAP* GO;

int c=0;

while (!key[KEY_ESC] && *i<10)
{
clear_bitmap(Buffer);

blit(present, Buffer, 0, 0, 0, 0, present->w, present->h);
usleep(50000);
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

if(key[KEY_SPACE])
{
c++;
}

if(c==1)
{
draw_sprite(present, darkness,0,0);
usleep(50000);
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}

if(c==2)
{

draw_sprite(present, office,0,0);
usleep(90000);
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

}

if(c==3)
{

draw_sprite(present, sallebain,0,0);
usleep(90000);
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);

}

if(c==4)
{

if(*i<5){
draw_sprite(Buffer, menu[(*i)],0,0);
}else if(*i==6){
draw_sprite(Buffer, level1,0,0);
}else if(*i==7){
draw_sprite(Buffer, instruction,0,0);
}
blit(Buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);



if (key[KEY_DOWN])
{
usleep(90000);

(*i)++;

if ((*i)==4) 
{
(*i)=1;
}

}

if((*i)==1)
{
if(key[KEY_ENTER])
{
level1=load_bitmap("level1.bmp",NULL);
(*i) =6;

if(key[KEY_ENTER])
{
draw_sprite(Buffer, youmust,0,0);

//if(key[KEY_ENTER])
//{
//clear(Buffer);
//Background = load_bitmap("background.bmp", NULL);
//draw_sprite(Buffer, curseur, 0, 0);
//draw_sprite(Buffer, Background, 0, 0);


//draw_images(&image1, &image2, &image3, &image4, &image5, &image6, &image7, &image8, &image9, &image10, &image11, &image12, GO, &box1, &box2, &box3, &box4, &box5, &box6, &box7, curseur, Buffer);

//clic(&image1, &image2, &image3, &image4, &image5, &image6, &image7, &image8, &image9, &image10, &image11, &image12, GO, &box1, &box2, &box3, &box4, &box5, &box6, &box7, curseur, Buffer);
//}
}
}
}
if((*i)==2)
{
if(key[KEY_ENTER])
{
instruction=load_bitmap("instruction.bmp",NULL);
(*i)=7;
}
}  

if((*i)==3)
{
if(key[KEY_ENTER])
{
(*i)=11;
}
}  

}
}
}


void load (BITMAP *menu[4],BITMAP *instruction,BITMAP *level1,BITMAP *present,BITMAP *darkness,BITMAP *office,BITMAP *sallebain,BITMAP *youmust)
{

menu[0]=load_bitmap("menu1.bmp",NULL);
menu[1]=load_bitmap("menu2.bmp",NULL);
menu[2]=load_bitmap("menu3.bmp",NULL);
menu[3]=load_bitmap("menu4.bmp",NULL);

present = load_bitmap("./fame.bmp", NULL);
darkness = load_bitmap("./darknessfall.bmp", NULL);
office = load_bitmap("./office.bmp", NULL);
sallebain = load_bitmap("./salledebain1.bmp", NULL);
youmust = load_bitmap("./youmust.bmp", NULL);

if (menu[0] == NULL) {
allegro_message("could not load images");
allegro_exit();
}
}
